package com.smartwebx.ha.dal.realtime.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.smartwebx.ha.dal.config.OracleConfigInfo;
import com.smartwebx.ha.dal.inter.water.IQProcessDataOperatDao;
import com.smartwebx.ha.dal.inter.water.IZProcessDataOperatDao;
import com.smartwebx.ha.dal.usebean.DateValue;

/**
 * 泵站
 * 
 * @author zhangxi
 * 
 */
public interface PumpMapper extends IZProcessDataOperatDao,
		IQProcessDataOperatDao {

	String ST_PUMP_R = OracleConfigInfo.REALTIME_NAME + ".ST_PUMP_R";

	@Select("SELECT TM,PPUPZ val FROM " + ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM>=#{startHour} AND TM<#{endHour}")
	public List<DateValue> getSingleStatHourZProcess(
			@Param("stcd") String stcd, @Param("startHour") Date startHour,
			@Param("endHour") Date endHour);

	@Select("SELECT TM,PPUPZ val FROM "
			+ ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM>=#{startDate} AND TM<#{endDate} AND to_char(TM,'HH24')=8")
	public List<DateValue> getSingleStatDayZProcess(@Param("stcd") String stcd,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate);

	@Select("SELECT TM,PPUPZ val FROM "
			+ ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM<#{datePoint} AND ROWNUM=1 ORDER BY TM DESC")
	public DateValue getStartHourBeforeZVal(@Param("stcd") String stcd,
			@Param("datePoint") Date startHour);

	@Select("SELECT TM,PMPQ val FROM "
			+ ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM>=#{startDate} AND TM<#{endDate} AND to_char(TM,'HH24')=8")
	public List<DateValue> getSingleStatDayQProcess(@Param("stcd") String stcd,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate);

	@Select("SELECT TM,PMPQ val FROM " + ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM>=#{startHour} AND TM<#{endHour}")
	public List<DateValue> getSingleStatHourQProcess(
			@Param("stcd") String stcd, @Param("startHour") Date startHour,
			@Param("endHour") Date endHour);

	@Select("SELECT TM,PMPQ val FROM "
			+ ST_PUMP_R
			+ " WHERE STCD = #{stcd} AND TM<#{datePoint} AND ROWNUM=1 ORDER BY TM DESC")
	public DateValue getStartHourBeforeQVal(@Param("stcd") String stcd,
			@Param("datePoint") Date startHour);

}
